/**
 * 检查登录逻辑
 * @author houxy
 */
function login() {
    $("#login").click(function () {
        //获取数据
        let userName = $("#userName").val().trim();
        let password = $("#password").val().trim();
        let check = true;//通过检测
        if (userName == "") {
            alert("用户名不能为空");
            check = false;
        }
        if (password == "") {
            alert("密码不能为空");
            check = false;
        }
        if (check) {
            $.ajax({
                url: "checklogin",
                type: "post",
                async: false,
                data: {"userName": userName, "password": password},
                dataType: "json",
                success: function (data) {
                    var msg = data.msg;
                    if (msg == "可以登录") {
                        window.location.href = "desktop";
                    } else {
                        alert(msg);
                    }
                },
                error: function () {
                    alert("登录异常，请稍后重试");
                }
            })
        }
    });
}